#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Import('env')
import os

build_dir = env.get('BUILD_DIR')

env.AppendUnique(CPPPATH=[
    os.path.join(Dir('.').abspath, 'include'),
    os.path.join('#', 'resource', 'c_common')
])

if env.get('TARGET_OS') == 'tizen':
    env.AppendUnique(LIBPATH=[build_dir])
else:
    env.AppendUnique(
        LIBPATH=[os.path.join(build_dir, 'resource', 'csdk', 'logger')])
if env.get('OIC_SUPPORT_TIZEN_TRACE') == 'True':
    env.AppendUnique(CPPDEFINES=['OIC_SUPPORT_TIZEN_TRACE'])

if env.get('TARGET_OS') == 'webos':
    env.AppendUnique(CPPDEFINES=['__webos__'])
    env.ParseConfig("pkg-config --cflags --libs PmLogLib")
    env.ParseConfig("pkg-config --cflags --libs glib-2.0")

local_env = env.Clone()

######################################################################
# Source files and Targets
######################################################################
logger_src = ['./src/logger.c', './src/trace.c']

loggerlib = local_env.StaticLibrary('logger', logger_src)
local_env.InstallTarget(loggerlib, 'logger')
local_env.UserInstallTargetHeader('include/experimental/logger_types.h',
                                  'c_common/experimental', 'logger_types.h')
local_env.UserInstallTargetHeader('include/experimental/logger.h',
                                  'c_common/experimental', 'logger.h')
